package top.yihoxu.consumer;

import top.yihoxu.common.model.User;
import top.yihoxu.common.service.UserService;
import top.yihoxu.proxy.ServiceProxyFactory;

/**
 * @Author dth
 * @Date 2024/5/21 14:28
 * @PackageName:top.yihoxu.consumer
 * @ClassName: EasyConsumerExample
 * @Description: 简易服务消费者示例
 * @Version 1.0
 */
public class EasyConsumerExample {
    public static void main(String[] args) {
        //todo 需要获取UserService的实现类对象
//        UserService userService=null;
        //静态代理
        //UserService userService = new UserServiceProxy();
        //动态代理
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
        User user = new User();
        user.setName("yihoxu");
        //调用
        User newUser = userService.getUser(user);
        if (newUser != null) {
            System.out.println(newUser.getName());
        } else {
            System.out.println("user==null");
        }
    }
}
